package com.briup.day11;

import lombok.*;

// 自动生成get/set/toString等方法
@Data
// 添加全参构造器
@AllArgsConstructor
@NoArgsConstructor
public abstract class Animal {
    private String name;

    // 设置一个makeSound方法，用于输出动物的叫声
    public abstract void makeSound();

    // move方法，用于记录动物的行为
    public abstract void move();
}

@EqualsAndHashCode(callSuper = true)
@Data
class Cat extends Animal {
    private String color;

    public Cat(String name, String color) {
        super(name);
        this.color = color;
    }

    @Override
    public void makeSound() {
        System.out.println("小猫喵喵叫");
    }

    @Override
    public void move() {
        System.out.println("小猫会以每秒7次动作的速度进行捕猎");
    }
}

@EqualsAndHashCode(callSuper = true)
@Data
class Dog extends Animal {
    private int age;

    public Dog(String name, int age) {
        super(name);
        this.age = age;
    }

    @Override
    public void makeSound() {
        System.out.println("小狗汪汪叫");
    }

    @Override
    public void move() {
        System.out.println("小狗用四脚奔跑");
    }
}

@EqualsAndHashCode(callSuper = true)
@Data
class Bird extends Animal {
    private String wingSpan;

    public Bird(String name, String wingSpan) {
        super(name);
        this.wingSpan = wingSpan;
    }

    @Override
    public void makeSound() {
        System.out.println("小鸟叽叽喳喳叫");
    }

    @Override
    public void move() {
        System.out.println("小鸟会使用翼展进行飞行");
    }
}

class Test {
    public static void main(String[] args) {
        Cat cat = new Cat("小黑", "白色");
        cat.move();
        cat.makeSound();
    }
}
